package org.rabbit.web;

import java.util.List;

import org.rabbit.pojo.Product;
import org.rabbit.service.ProductService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

@RestController
@CrossOrigin(value= {"*"},allowCredentials="true")
public class ProductController {

	@Reference
	private ProductService ps;
	
	
	@RequestMapping("index")
	public List<Product> index() {
		List<Product> pl = ps.findAll();
		//System.out.println(pl+"3333");
		return pl;
	}
	
	
	@RequestMapping("getOne/{pid}")
	public Product getOne(@PathVariable("pid")Integer pid) {

		System.out.println(pid);
		Product p = ps.findOneByPid(pid);
		System.out.println(p+"))))))))");
		return p;
	}
	
}
